﻿create PROCEDURE Sync.SP_BoardLoans_SelectChanges
@LastRowVersion rowversion,
@FilterdColumn UNIQUEIDENTIFIER
AS 
BEGIN 
	SELECT 
        t.[BoardID],t.[LoanID],
		g.[EnteringNotes],g.[BoardLoanAmount],g.[BoardPaymentPeriod],g.[BoardpaymentMethodID],g.[StatusNotes],
		t.IsDeleted,
		t.LastUpdatedDate
	FROM [dbo].[BoardLoans] g RIGHT JOIN Sync.BoardLoans_Tracking t  
    ON t.BoardID = g.BoardID AND t.LoanID = g.LoanID 
    join [Board] b
		on b.BoardID = g.BoardID
	WHERE (@LastRowVersion IS NULL OR t.Version > @LastRowVersion)
	AND ((@FilterdColumn IS NULL) OR (b.CommitteeID = @FilterdColumn))
    END











